package com.sea.app.common.Entity;

import java.util.List;

/**
 * Created by 31417 on 2017/4/29.
 */
public class Page<T> {
    //当前页号
    private Integer index;
    //页大小
    private Integer size;
    //总条数
    private Long count;
    //页数据
    private List<T> list;

    public Page() {

    }

    public Page(long count, List<T> list){
        this.count = count;
        this.list = list;
    }
    //最大页数
    public Long maxIndex(){
        return count%index==0?count/index:(count/index)+1;
    }

    //开始条数
    public Integer limitStart(){
        return (getIndex()-1)*getSize();
    }
    //接收条数
    public Integer limitEnd(){
        return getIndex() * getSize();
    }

    public Integer getIndex() {
        return index==null?1:index;
    }

    public void setIndex(Integer index) {
        this.index = index;
    }

    public Integer getSize() {
        return size== null?5:size;
    }

    public void setSize(Integer size) {
        this.size = size;
    }

    public Long getCount() {
        return count;
    }

    public Page<T> setCount(Long count) {
        this.count = count;
        return this;
    }

    public List<T> getList() {
        return list;
    }

    public Page<T> setList(List<T> list) {
        this.list = list;
        return this;
    }
}
